﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace XDA_ROM_Hub
{
    public partial class DSE : Form
    {
        public DSE()
        {
            InitializeComponent();
        }



        private void DSE_Load(object sender, EventArgs e)
        {

        }

        bool dresults;

        public void ChooseFolder()
        {
            MessageBox.Show("Please select your device (SD Card)", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
            DialogResult results = RomPath.ShowDialog();
            if (results == DialogResult.OK)
            {
                dresults = true;
                Properties.Settings.Default.RomPath = RomPath.SelectedPath;
            }
            else
            {
                dresults = false;
            }
        }



        private void button3_Click(object sender, EventArgs e)
        {
            try
            {
                ChooseFolder();
                Properties.Settings.Default.RomFileName = "AOSP_ICS_Keyboard.zip";
                Properties.Settings.Default.AddonURL = "http://xperiaromhub.fav.cc/rom_addons/" + Properties.Settings.Default.RomFileName;
                if (dresults == true)
                {
                    ProgressAddon prog = new ProgressAddon();
                    prog.Show();
                }
            }

            catch { }
        }


        private void button5_Click(object sender, EventArgs e)
        {
            try
            {
                ChooseFolder();
                if (Properties.Settings.Default.SelectedDevice.Contains("Live"))
                {
                    Properties.Settings.Default.RomFileName = "walkman_app.zip";
                }
                else if (!Properties.Settings.Default.SelectedDevice.Contains("Live"))
                {
                    MessageBox.Show("Only for Xperia Live, Continue at your own risk", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }

                Properties.Settings.Default.AddonURL = "http://xperiaromhub.fav.cc/rom_addons/" + Properties.Settings.Default.RomFileName;
                if (dresults == true)
                {
                    ProgressAddon prog = new ProgressAddon();
                    prog.Show();
                }
            }
            catch { }
        }

        private void button6_Click(object sender, EventArgs e)
        {
            ChooseFolder();
            Properties.Settings.Default.RomFileName = "Apollo.zip";
            Properties.Settings.Default.AddonURL = "http://xperiaromhub.fav.cc/rom_addons/" + Properties.Settings.Default.RomFileName;
            if (dresults == true)
            {
                ProgressAddon prog = new ProgressAddon();
                prog.Show();
            }
        }

        private void button7_Click(object sender, EventArgs e)
        {

            this.Hide();
        }

        private void button8_Click(object sender, EventArgs e)
        {
            Properties.Settings.Default.RomPath = Application.StartupPath;
            Properties.Settings.Default.RomFileName = "BA_CM9_Cid.zip";
            Properties.Settings.Default.AnimationName = "BA_CM9_Cid.zip";
            Properties.Settings.Default.AddonURL = "http://xperiaromhub.fav.cc/rom_addons/" + Properties.Settings.Default.RomFileName;
            
                ProgressAddon prog = new ProgressAddon();
                Properties.Settings.Default.IsBootAnimation = true;
                prog.Show();
            
        }

        private void button9_Click(object sender, EventArgs e)
        {
            ChooseFolder();
            Properties.Settings.Default.RomFileName = "Keyboard_HTC_IME.zip";
            Properties.Settings.Default.AddonURL = "http://xperiaromhub.fav.cc/rom_addons/" + Properties.Settings.Default.RomFileName;
            if (dresults == true)
            {
                ProgressAddon prog = new ProgressAddon();
                prog.Show();
            }
        }

        public void boot_animation_flasher()
        {
            try
            {
                try
                {
                    string strCmdText = "push " + Properties.Settings.Default.AnimationName + " system/media/bootanimation.zip";

                    System.Diagnostics.Process.Start(Application.StartupPath + @"\BIN\adb.exe", strCmdText);

                }
                finally
                {
                    string strCmdText = "shell chmod 655 system/media/bootanimation.zip";

                    System.Diagnostics.Process.Start(Application.StartupPath + @"\BIN\adb.exe", strCmdText);

                }
            }
            finally
            {
                string strCmdText = "reboot";

                System.Diagnostics.Process.Start(Application.StartupPath + @"\BIN\adb.exe", strCmdText);
                MessageBox.Show("Boot animation replaced.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            
                Properties.Settings.Default.RomPath = Application.StartupPath;
                Properties.Settings.Default.RomFileName = "BA_Android_Particles.zip";
                Properties.Settings.Default.AnimationName = "BA_Android_Particles.zip";
            Properties.Settings.Default.AddonURL = "http://xperiaromhub.fav.cc/rom_addons/" + Properties.Settings.Default.RomFileName;
            
                ProgressAddon prog = new ProgressAddon();
                Properties.Settings.Default.IsBootAnimation = true;
                prog.Show();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            Properties.Settings.Default.RomPath = Application.StartupPath;
            Properties.Settings.Default.RomFileName = "BA_Android_Particles_Blue.zip";
            Properties.Settings.Default.AnimationName = "BA_Android_Particles_Blue.zip";
            Properties.Settings.Default.AddonURL = "http://xperiaromhub.fav.cc/rom_addons/" + Properties.Settings.Default.RomFileName;

            ProgressAddon prog = new ProgressAddon();
            Properties.Settings.Default.IsBootAnimation = true;
            prog.Show();
        }

        private void button12_Click(object sender, EventArgs e)
        {
            Properties.Settings.Default.RomPath = Application.StartupPath;
            Properties.Settings.Default.RomFileName = "BA_LuniarUI.zip";
            Properties.Settings.Default.AnimationName = "BA_LuniarUI.zip";
            Properties.Settings.Default.AddonURL = "http://xperiaromhub.fav.cc/rom_addons/" + Properties.Settings.Default.RomFileName;

            ProgressAddon prog = new ProgressAddon();
            Properties.Settings.Default.IsBootAnimation = true;
            prog.Show();
        }

        private void button4_Click(object sender, EventArgs e)
        {
            Properties.Settings.Default.RomPath = Application.StartupPath;
            Properties.Settings.Default.RomFileName = "BA_DBB_Alongenemylines.zip";
            Properties.Settings.Default.AnimationName = "BA_DBB_Alongenemylines.zip";
            Properties.Settings.Default.AddonURL = "http://xperiaromhub.fav.cc/rom_addons/" + Properties.Settings.Default.RomFileName;

            ProgressAddon prog = new ProgressAddon();
            Properties.Settings.Default.IsBootAnimation = true;
            prog.Show();
        }

        private void button10_Click(object sender, EventArgs e)
        {
            Properties.Settings.Default.RomPath = Application.StartupPath;
            Properties.Settings.Default.RomFileName = "BA_DBB_Ctbeiser.zip";
            Properties.Settings.Default.AnimationName = "BA_DBB_Ctbeiser.zip";
            Properties.Settings.Default.AddonURL = "http://xperiaromhub.fav.cc/rom_addons/" + Properties.Settings.Default.RomFileName;

            ProgressAddon prog = new ProgressAddon();
            Properties.Settings.Default.IsBootAnimation = true;
            prog.Show();
        }

        private void button11_Click(object sender, EventArgs e)
        {
            Properties.Settings.Default.RomPath = Application.StartupPath;
            Properties.Settings.Default.RomFileName = "BA_DBB_Rob_Turner.zip";
            Properties.Settings.Default.AnimationName = "BA_DBB_Rob_Turner.zip";
            Properties.Settings.Default.AddonURL = "http://xperiaromhub.fav.cc/rom_addons/" + Properties.Settings.Default.RomFileName;

            ProgressAddon prog = new ProgressAddon();
            Properties.Settings.Default.IsBootAnimation = true;
            prog.Show();
        }

        private void button13_Click(object sender, EventArgs e)
        {
            Properties.Settings.Default.RomPath = Application.StartupPath;
            Properties.Settings.Default.RomFileName = "BA_Resident_Evil.zip";
            Properties.Settings.Default.AnimationName = "BA_Resident_Evil.zip";
            Properties.Settings.Default.AddonURL = "http://xperiaromhub.fav.cc/rom_addons/" + Properties.Settings.Default.RomFileName;

            ProgressAddon prog = new ProgressAddon();
            Properties.Settings.Default.IsBootAnimation = true;
            prog.Show();
        }
    }
}
